//
// Ephi - simulation of magnetic fields and particles
// Copyright (C) 2007 Indrek Mandre <indrek(at)mare.ee>
// For more information please see http://www.mare.ee/indrek/ephi/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//

// visualize the pmap of a charge ball close by

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <vector>

#include "ephi.hpp"

#define PMAP_BOX 0.1

int main (int argc, char *argv[])
{
  Ephi::setDebugLevel (Ephi::DEBUG_APP);

  PMap pmap(vect3d(0.1, 0.1, 0.1), 0.01, 0, 0.03);
  pmap.addQ (vect3d(0, 0, 0), vect3d(0, 0, 0), -ELEMENTARY_CHARGE);
  pmap.recalc();
  Statics statics;
  statics.addStaticElement (new StaticPMap(pmap));
  ElectroDynamics dyn(statics);

  printf ("Pot at left-: %g\n", pmap.getPotential (vect3d(-0.030001, 0, 0)));
  printf ("Pot at left+: %g\n", pmap.getPotential (vect3d(-0.029999, 0, 0)));

  Scene scene(dyn);
  Screen screen(800, 800, 0.1, 0.1);
  scene.calc (screen, Scene::CALC_POTENTIAL);
  scene.set_coloring (20, false);
  scene.render_map (screen);
  screen.draw_cross (vect3d(-0.0301, 0, 0), Screen::BLUE);
  screen.write ("test23_pot.bmp");
  scene.calc (screen, Scene::CALC_EFIELD);
  scene.set_coloring (0, true);
  scene.render_map (screen);
  screen.draw_cross (vect3d(-0.0301, 0, 0), Screen::BLUE);
  screen.write ("test23_efield.bmp");

  
  return 0;
}

